<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@include file="/context/mytags.jsp" %>
<t:base type="jquery,easyui,tools"/>
<div class="easyui-layout" fit="true" id="main_questList">
    <div region="center" style="padding:1px;">
        <t:datagrid name="questList" title="" actionUrl="questController.do?datagrid" idField="id" fit="true"
                    queryMode="group">
            <t:dgCol title="主键" field="id"></t:dgCol>
            <t:dgCol title="名称" field="name" width="4" query="true"></t:dgCol>
            <t:dgCol title="分类" field="questSortEntity.name" width="2" query="true"></t:dgCol>
            <t:dgCol title="平台" field="platformEntity.name" width="2" query="true"></t:dgCol>
            <t:dgCol title="有效" field="effective" dictionary="isno" query="true"></t:dgCol>
            <%--<t:dgCol title="背景图片" field="backgroud" image="true" imageSize="200,100" width="2"></t:dgCol>--%>
            <%--<t:dgCol title="创建时间" formatter="yyyy-MM-dd hh:mm:ss" field="createTime"></t:dgCol>--%>

            <t:dgCol title="common.operation" field="opt" width="4"></t:dgCol>
            <t:dgDelOpt url="questController.do?del&id={id}" title="删除"></t:dgDelOpt>
            <t:dgConfOpt exp="effective#eq#1" url="questController.do?stop_or_start&id={id}" title="禁用"
                         message="是否禁用此量表？"></t:dgConfOpt>
            <t:dgConfOpt exp="effective#eq#0" url="questController.do?stop_or_start&id={id}" title="启用"
                         message="是否启用此量表？"></t:dgConfOpt>
            <t:dgFunOpt funname="showQuesQues(id,name)" title="问题"></t:dgFunOpt>
            <t:dgFunOpt funname="showQuesDim(id,name)" title="纬度"></t:dgFunOpt>

            <%--<t:dgFunOpt funname="f_importTemplate(id)" title="导入模版"></t:dgFunOpt>--%>

            <t:dgToolBar title="新增" icon="icon-add" url="questController.do?addorupdate" funname="add" width="800"
                         height="700"></t:dgToolBar>
            <t:dgToolBar title="修改" icon="icon-edit" url="questController.do?addorupdate" funname="f_updateInfo"
                         width="800" height="700"></t:dgToolBar>
            <t:dgToolBar title="预览" icon="icon-search" url="questController.do?detail" funname="f_detail" width="800"
                         height="700"></t:dgToolBar>

        </t:datagrid>
    </div>
</div>
<%--<div region="east" split="true">--%>
<%--<div tools="#tt" class="easyui-panel" title='量表问题' style="padding: 10px;"--%>
<%--fit="true" border="false" id="function-panel"></div>--%>
<%--</div>--%>
<%--<div id="tt"></div>--%>
<%--</div>--%>
<div data-options="region:'east',
	title:'标题',
	collapsed:true,
	split:true,
	border:false,
	onExpand : function(){
		li_east = 1;
	},
	onCollapse : function() {
	    li_east = 0;
	}"
     style="width: 900px; overflow: hidden;" id="eastPanel">
    <div class="easyui-panel" style="padding: 1px;" fit="true" border="false" id="showPanel"></div>
</div>

<script type="text/javascript">
    $(function () {
        var li_east = 0;
        $(".datagrid-toolbar").eq(1).append('<input align="right" type="button" id="importData" style="width: 100px;" value="模版导入" onclick="f_importTemplate()">');
    });
    //    function showQuesQues(id, name) {
    //        $("#function-panel").panel(
    //                {
    //                    title: name,
    //                    href: "quesquesController.do?index&id=" + id
    //                }
    //        );
    //        $('#function-panel').panel("refresh");
    ////        var url = "quesquesController.do?index&id=" + id;
    ////        createdetailwindow(name, url, window.innerWidth, window.innerHeight);
    //    }

    function showQuesQues(id, name) {
        var title = "问题【" + name + "】";
        if (li_east == 0) {
            $('#main_questList').layout('expand', 'east');
        }
        $('#main_questList').layout('panel', 'east').panel('setTitle', title);
        $('#main_questList').layout('panel', 'east').panel('resize');
        $('#showPanel').panel("refresh", "quesquesController.do?index&id=" + id);
    }

    function showQuesDim(id, name) {
        var title = "纬度【" + name + "】";
        if (li_east == 0) {
            $('#main_questList').layout('expand', 'east');
        }
        $('#main_questList').layout('panel', 'east').panel('setTitle', title);
        $('#main_questList').layout('panel', 'east').panel('resize');
        $('#showPanel').panel("refresh", "cqDimController.do?index&id=" + id);
//        var url = "cqDimController.do?index&id=" + id;
//        createdetailwindow(name, url, window.innerWidth, window.innerHeight);
    }


    function f_updateInfo(title, url, id, width, height) {
        gridname = id;
        var rowsData = $('#' + id).datagrid('getSelections');
        if (!rowsData || rowsData.length == 0) {
            tip('请选择编辑量表');
            return;
        }
        if (rowsData.length > 1) {
            tip('请选择一条量表再编辑');
            return;
        }

        url += '&id=' + rowsData[0].id;
        createwindow(title, url, width, height);
    }


    //查看
    function f_detail(title, url, id, width, height) {
        gridname = id;
        var rowsData = $('#' + id).datagrid('getSelections');
        if (!rowsData || rowsData.length == 0) {
            tip('请选择量表');
            return;
        }
        if (rowsData.length > 1) {
            tip('请选择一个量表');
            return;
        }
        url += '&id=' + rowsData[0].id;
        createdetailwindow(title, url, width, height);
    }

    //   模版导入
    function f_importTemplate() {
//        var url = "questController.do?importTemplate&id=" + id;
        title = "量表模版";
        var url = "questController.do?importTemplate";
        createwindow(title, url, 800, 600);

    }
</script>
